package com.dongdongshop.service.impl;

import com.dongdongshop.dao.AddressRepostory;
import com.dongdongshop.pojo.user.TbAddress;
import com.dongdongshop.service.user.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
 * @Author Eayon
 * @Date 2020/4/4 21:55
 */
@Service
public class AddressServiceImpl implements AddressService {

    @Autowired
    private AddressRepostory addressRepostory;

    @Override
    public List<TbAddress> findAddressByUserId(String userId) {
        List<TbAddress> addresses = addressRepostory.findByUserId(userId);
        return addresses;
    }

    @Override
    public TbAddress findAddressById(Long id) {
        Optional<TbAddress> optional = addressRepostory.findById(id);
        TbAddress address = optional.get();
        return address;
    }
}
